Provide msecsTo in DateTime for Qt 4.6.
authorrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 19 Jul 2013 17:01:07 +0000 (17:01 +0000)
committerrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 19 Jul 2013 17:01:07 +0000 (17:01 +0000)
gpsbabel/src/core/datetime.h

index 4cab6842898c188ff21658f437f40e8c95bf8d42..cebb55b94657d5a2c3e4b86fef548d62b09fecc1 100644 (file)
@@ -104,6 +104,14 @@ public:
     QTime time(this->time());
     return time.hour() * 10000 + time.minute() * 100 + time.second();
   }
+  // Qt 4.6 and under doesn't have msecsTo.  Fortunately, it's easy to
+  // provide.  It's a 64-bit because if the times aren't on the same day,
+  // the returned value can be quite large.
+  int64_t msecsTo(const QDateTime& dt) {
+    qint64 days = this->daysTo(dt);
+    qint64 msecs = this->time().msecsTo(dt.time());
+    return days * (1000 * 3600 * 24) + msecs;
+  }
 
   // Like toString, but with subsecond time that's included only when
   // the trailing digits aren't .000.  Always UTC.
@@ -116,6 +124,7 @@ public:
     }
     return this->toUTC().toString(format);
   }
 
  private:
   time_t t_;